//
//  ST_UserCenterTagCell.swift
//  BTVideo
//
//  Created by DouLei on 2019/9/26.
//  Copyright © 2019 DouLei. All rights reserved.
//

import UIKit
import SnapKit
import SwifterSwift
import SDWebImage


class ST_UserCenterTagCell: UICollectionViewCell {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.contentView.addSubview(backView)
        backView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        self.contentView.addSubview(mark_image_view)
        mark_image_view.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.width.equalTo(13)
            make.height.equalTo(15)
            make.left.equalToSuperview().offset(12)
        }
        
        self.contentView.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-12)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    fileprivate lazy var backView:UIView = {
        let control = UIView()
        control.cornerRadius = 14
        control.borderColor = Color.init(hexString: "#F2F4F7")
        control.borderWidth = 1
        control.backgroundColor = Color.init(hexString: "#F9FBFD")
        return control
    }()
     
    fileprivate lazy var mark_image_view:UIImageView = {
        let control = UIImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        return control
    }()

    fileprivate lazy var content_label:UILabel = {
        let control = UILabel.init()
        control.text = ""
        control.textColor = Color.init(hexString: "#333333")
        control.textAlignment = .right
        control.font = UIFont.systemFont(ofSize: 12, weight: UIFont.Weight.regular)
        return control
    }()
    
    
//    MARK: - Bind Model
    var model = UserPreviewTagModel(){
        didSet{
            
            content_label.text = model.title
            
            
            mark_image_view.pin_setImage(from: model.icon_url.compress_image().url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
        }
    }
}
